<!--div id="loader" class="container"-->
    <div class="col-md-offset-1">
        <div class="col-md-11">
			<div class="panel-body well">
				<div>
					<table width="30%" border=0>
					<tr><td width="10%"><b>Type Name</td><td width="1%">:</b></td><td width="10%"><?php echo $header_data['MST_TYPE_DESC']; ?></td></tr> 
					<tr><td><b>Room Name</td><td>:</b></td><td><?php echo $header_data['MST_CATEGORY_DESC']; ?></td></tr>
					<tr><td><b>Floor</td><td>:</b></td><td><?php echo $header_data['MST_FLOOR_DESC']; ?></td></tr>
					</table>
				</div><hr color="red">
				<h4><b class="caret"></b><b> View Room Item List</b></h4>
				<table class="table table-bordered table-condensed table-striped" style="background:#f9f9f9;">
					<thead>
						<tr>
							<th class="tblhead" style="width:5px;text-align:center;">No</th>
							<!--th class="tblhead" style="width:25px;text-align:center;">Item ID</th-->
							<th class="tblhead" style="width:25px;text-align:center;">Item Name</th>
							<th class="tblhead" style="width:15px;text-align:center;">Item Qty</th>
							<th class="tblhead" style="width:15px;text-align:center;">Item Uom</th>                        
							<th class="tblhead" style="width:15px;text-align:center;">Action</th>
						</tr>
					</thead>
					<tbody>
						<?php
						if (empty($list_data)) {
							?>
							<tr><td colspan="9" style="text-align:center">No Data Available</td></tr>
							<?php
						} else {
							$i=1;
							foreach ($list_data as $row) {							
								?>
								<tr>
									<td bgcolor="#FFFFFF" class="tbl-content-c" style="text-align:center;"><?php echo $i; ?>.</td>
									<?php
									$public_room_id 	= $row["ITEM_PUBLIC_ROOM_ID"];
									$public_room_name 	= $row["ITEM_PUBLIC_ROOM_NAME"];
									$public_room_qty 	= $row["ITEM_PUBLIC_ROOM_QTY"];
									$public_room_uom	= $row["ITEM_PUBLIC_ROOM_UOM"];                                
									?>
									
									<!--td bgcolor="#FFFFFF" class="tbl-content-c" style="text-align:left;"><?php //echo $public_room_id; ?></td-->
									<td bgcolor="#FFFFFF" class="tbl-content-c" style="text-align:left;"><?php echo $public_room_name; ?></td>
									<td bgcolor="#FFFFFF" class="tbl-content-c" style="text-align:left;"><?php echo $public_room_qty; ?></td>								
									<td bgcolor="#FFFFFF" class="tbl-content-c" style="text-align:left;"><?php echo $public_room_uom; ?></td>
									
									<?php $i++; ?>
									
									<td bgcolor="#FFFFFF" class="tbl-content-c" style="text-align:center;">
										<a class="btn btn-sm btn-warning" href="#" onclick="edit_detail('<?php echo $room_id ?>','<?php echo $type ?>','<?php echo $public_room_id ?>');">
											<!--span class="glyphicon glyphicon-edit"></span--> Edit</a>
										<a class="btn btn-sm btn-danger" href="#" onclick="delete_data('<?php echo $room_id ?>','<?php echo $type ?>','<?php echo $public_room_id ?>','<?php echo $public_room_name ?>');">
											<!--span class="glyphicon glyphicon-remove"></span--> Delete</a>
									</td>
								</tr>
								<?php
							}
						}
						?>
					</tbody>
				</table>
				<div class="col-sm-8">
					<div class="col-sm-4"><label for="button" class="control-label">&nbsp;</label></div>
					<div class="col-sm-4">
						<button type="submit" class="btn btn-success btn-block" onclick="add('<?php echo $room_id ?>','<?php echo $type ?>');">
						<!--span class="glyphicon glyphicon-plus"></span--> Add New</button>
					</div>
					<div class="col-sm-4">
						<button type="button" class="btn btn-default btn-block" onclick="cancel();">
						<!--span class="glyphicon glyphicon-circle-arrow-left"></span--> Finish</button>
					</div>
				</div>
			</div>			
		</div>
    </div>
<!--/div-->

<script type="text/javascript">
	function cancel() {
        $.post("<?= site_url() ?>setup/result_room", function(data) {
			window.location = '<?php echo base_url();?>setup/room';
        });
    }
	
	function add(room_id,type){		
		$.post("<?= site_url() ?>setup/add_detail", {room_id: room_id, type: type}, function(data) {
            $('#loader').html(data);
        });
	}
	
	function edit_detail(room_id,type,public_room_id){		
		$.post("<?= site_url() ?>setup/edit_detail", {room_id: room_id, type: type, public_room_id: public_room_id}, function(data) {
            $('#loader').html(data);
        });
	}
	
	function delete_data(room_id,type,public_room_id,public_room_name){		
		if (confirm("Apakah Anda Yakin Ingin Delete Item '"+ public_room_name +"' ?")){
			$.post("<?= site_url() ?>setup/delete_detail", {room_id: room_id, type: type, public_room_id: public_room_id}, function(data) {
				$('#loader').html(data);
			});
		}
	}
</script>
